package com.forezp.datastruct.singleLinkList;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by forezp on 2017/12/12.
 */
public class SingeLinkListCreater {


    public static Node createLinkList(List<Integer> list) {
        if (list == null || list.size() == 0) {
            return null;
        }
        Node firstNode = new Node(list.get(0));
        Node nextNode = createLinkList(list.subList(1, list.size()));
        firstNode.setNext(nextNode);
        return firstNode;

    }

    public static void main(String[] args) {
        Node.printNode(createLinkList(new ArrayList<>()));
        Node.printNode(createLinkList(Arrays.asList(1, 2)));
        Node.printNode(createLinkList(Arrays.asList(1, 2, 4, 4)));

    }



}
